<template>
  <div class="auth-container">
    <!-- Logo -->
    <div class="auth-logo">
      <img src="@/assets/logo.png" alt="爱迪智考" class="logo-image">
      <span class="logo-text">爱迪智考</span>
    </div>
    
    <!-- 背景动画 -->
    <div class="background-animation">
      <div class="circle circle-1"></div>
      <div class="circle circle-2"></div>
      <div class="circle circle-3"></div>
      <div class="circle circle-4"></div>
      <div class="circle circle-5"></div>
    </div>

    <!-- 主卡片 -->
    <div class="auth-card">
      <!-- 切换标签 -->
      <div class="auth-tabs">
        <router-link 
          class="tab-btn" 
          :class="{ active: $route.name === 'login' }" 
          :to="{ name: 'login' }">
          <i class="fas fa-sign-in-alt"></i> 登录
        </router-link>
        <router-link 
          class="tab-btn" 
          :class="{ active: $route.name === 'register' }" 
          :to="{ name: 'register' }">
          <i class="fas fa-user-plus"></i> 注册
        </router-link>
      </div>

      <!-- 表单区域 - 子路由将在这里渲染 -->
      <div class="auth-form">
        <router-view></router-view>
      </div>
    </div>

    <!-- 智能提示 -->
    <div class="smart-tips" :class="{ active: showTips }">
      <div class="tips-header">
        <i class="fas fa-lightbulb"></i> 智能提示
        <button class="close-tips" @click="showTips = false">
          <i class="fas fa-times"></i>
        </button>
      </div>
      <div class="tips-content">
        <p v-if="$route.name === 'login'">还没有账号？<router-link :to="{ name: 'register' }">立即注册</router-link></p>
        <p v-else-if="$route.name === 'register'">已有账号？<router-link :to="{ name: 'login' }">立即登录</router-link></p>
        <p v-else-if="$route.name === 'forgotPassword'">记起密码了？<router-link :to="{ name: 'login' }">立即登录</router-link></p>
        <p><i class="fas fa-shield-alt"></i> 我们使用高级加密技术保护您的信息安全</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'AuthContainer',
  data() {
    return {
      showTips: true
    }
  },
  methods: {
    showFeatureNotAvailable(type) {
      this.$message({
        message: `${type}功能暂未开放，敬请期待`,
        type: 'info',
        duration: 2000,
        showClose: true,
        center: true
      });
    }
  }
}
</script>

<style lang="less" scoped>
@import "@/styles/variables.less";

.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  height: 100vh;
  background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 100%);
  position: relative;
  overflow: hidden;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.auth-logo {
  position: absolute;
  top: 20px;
  left: 30px;
  display: flex;
  align-items: center;
  z-index: 3;
  
  .logo-image {
    height: 40px;
    border-radius: 8px;
    background: white;
    padding: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  }
  
  .logo-text {
    margin-left: 10px;
    font-size: 20px;
    font-weight: bold;
    color: @primary;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  }
}

.background-animation {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 0;

  .circle {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(@primary, 0.1), rgba(@secondary, 0.1));
    filter: blur(30px);
    animation: float 15s infinite ease-in-out;

    &.circle-1 {
      width: 300px;
      height: 300px;
      top: 10%;
      left: 10%;
      animation-delay: 0s;
      background: linear-gradient(135deg, rgba(@primary, 0.08), rgba(@secondary, 0.12));
    }

    &.circle-2 {
      width: 400px;
      height: 400px;
      bottom: 10%;
      right: 10%;
      animation-delay: 5s;
      background: linear-gradient(135deg, rgba(@primary, 0.07), rgba(@secondary, 0.1));
    }

    &.circle-3 {
      width: 200px;
      height: 200px;
      top: 50%;
      right: 20%;
      animation-delay: 10s;
      background: linear-gradient(135deg, rgba(@primary, 0.1), rgba(@secondary, 0.15));
    }
    
    &.circle-4 {
      width: 250px;
      height: 250px;
      bottom: 30%;
      left: 25%;
      animation-delay: 7s;
      background: linear-gradient(135deg, rgba(@primary, 0.06), rgba(@secondary, 0.09));
    }
    
    &.circle-5 {
      width: 180px;
      height: 180px;
      top: 20%;
      right: 30%;
      animation-delay: 12s;
      background: linear-gradient(135deg, rgba(@primary, 0.09), rgba(@secondary, 0.11));
    }
  }
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 450px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: all 0.3s ease;
  height: auto;
  max-height: 90vh;
  min-height: 490px;
  z-index: 1;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid @gray-200;

  .tab-btn {
    flex: 1;
    padding: 16px;
    background: none;
    border: none;
    font-size: 16px;
    font-weight: 500;
    color: @gray-600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    text-align: center;
    text-decoration: none;

    i {
      margin-right: 8px;
    }

    &.active {
      color: @primary;

      &::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 3px;
        background: @primary;
        border-radius: 3px 3px 0 0;
      }
    }

    &:hover {
      background: rgba(@primary, 0.05);
    }
  }
}

.auth-form {
  padding: 30px;
  flex: 1;
  overflow-y: auto;
  max-height: calc(90vh - 54px); /* 减去tabs的高度 */
}

.smart-tips {
  position: absolute;
  right: 20px;
  top: 20px;
  width: 250px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  padding: 15px;
  transform: translateX(120%);
  transition: all 0.5s ease;
  z-index: 2;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.6);

  &.active {
    transform: translateX(0);
  }

  .tips-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 500;
    color: @primary;

    i {
      margin-right: 8px;
    }

    .close-tips {
      background: none;
      border: none;
      color: @gray-500;
      cursor: pointer;
      font-size: 14px;

      &:hover {
        color: @gray-700;
      }
    }
  }

  .tips-content {
    font-size: 13px;
    color: @gray-600;

    p {
      margin: 8px 0;
      display: flex;
      align-items: center;

      i {
        margin-right: 8px;
        color: @primary;
      }

      a {
        color: @primary;
        text-decoration: none;
        margin-left: 5px;

        &:hover {
          text-decoration: underline;
        }
      }
    }
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-20px) rotate(5deg);
  }
}

@media (max-width: 768px) {
  .auth-container {
    padding: 10px;
  }

  .auth-card {
    height: auto;
  }

  .smart-tips {
    position: static;
    width: 100%;
    margin-top: 20px;
    transform: none;

    &.active {
      transform: none;
    }
  }
  
  .auth-logo {
    top: 15px;
    left: 15px;
    
    .logo-image {
      height: 30px;
    }
    
    .logo-text {
      font-size: 16px;
    }
  }
}
</style>